import numpy as np 
 
x =  [1,2,3] 
a = np.asarray(x)  
print (a)
print('='*32)

x =  (1,2,3) 
a = np.asarray(x)  
print (a)
print('='*32)

x =  [(1,2,3),(4,5,6)] # 此处元组数量必须保持一致
a = np.asarray(x)  
print (a)
print('='*32)

x =  [1,2,3] 
a = np.asarray(x, dtype =  float)  
print (a)
print('='*32)

s =  b'Hello World' 
a = np.frombuffer(s, dtype =  'S1')  
print (a)
print('='*32)

s =  'Hello World'
a = np.fromiter(list(s),dtype='U1')
print (a)
print('='*32)

# 使用 range 函数创建列表对象  
list=range(5)
it=iter(list)
 
# 使用迭代器创建 ndarray 
x=np.fromiter(it, dtype=float)
print(x)
print('='*32)